<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2022/12/8
 * Time: 9:40
 */

namespace app\controller;


class Upload
{
    public function upload(){
        // 获取表单上传文件 例如上传了001.jpg
        $file = request()->file('image');
        // 上传到本地服务器
        $savename = \think\facade\Filesystem::putFile( 'topic', $file,'public');
        $savename = str_replace('\\','/',$savename);
        return json(['code' => 200,'msg' => '','data' =>  '/storage/'.$savename]);
    }
}